using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using ShopForWeb.UI.Models;

namespace ShopForWeb.UI.Controllers
{
    [Route("[controller]")]
    public class StudentController : Controller
    {
        [HttpGet("{code}")]
       
         public IActionResult GetStudentByCode([FromRoute] string code){
            Student s=new Student(){
                Code=code,
                Name="张三",
                Birthday="1997-02-09",
                Address="山东省烟台市"
            };
            ViewData["student"]=s;
            return View();
         }
         
        [HttpGet("area")]
        public IActionResult GetStudentByAddress([FromQuery]string address){
            Student s=new Student(){
                Code="123123",
                Name="李四",
                Birthday="2000-02-09",
                Address=address,
            };
            ViewBag.Student=s;
            return View();

        }
        [HttpGet("name")]

        public IActionResult GetStudentByName([FromQuery]string name){
            Student s=new Student(){
                Code="19990203",
                Name=name,
                Birthday="1998-01-21",
                Address="山东省",

            };
            return View(s);
        }

        [HttpPost]

        public IActionResult AddNewStudent([FromForm]Student student){
            return Json(student);
        }

        [HttpPut]
         public IActionResult UpdateStudent([FromBody]Student student){
            return Json(student);
         }

         [HttpDelete ("{code}")]
         public IActionResult DelStudent([FromRoute]String code){
            return Json(new{Code= code });
         }
    }
}